package com.changyue.activity.me;

import android.content.Context;
import android.content.Intent;
import android.graphics.Paint;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;

import com.changyue.activity.basic.BasicActivity;
import com.changyue.blood.R;
import com.changyue.blood.databinding.ActivityAboutBinding;

public class AboutActivity extends BasicActivity {

    ActivityAboutBinding binding;

    public static void start(Context context) {
        Intent intent = new Intent(context, AboutActivity.class);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        binding = ActivityAboutBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        initView();
    }

    public void initView() {
        binding.line.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);
        binding.line.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String phoneNum = binding.line.getText().toString().replace("热线：", "");
                Intent intent = new Intent(Intent.ACTION_CALL);
                Uri data = Uri.parse("tel:" + phoneNum);
                intent.setData(data);
                startActivity(intent);
            }
        });

        binding.mail.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);
        binding.mail.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String phoneNum = binding.mail.getText().toString().replace("邮箱：", "");
                Intent intent = new Intent(Intent.ACTION_SEND);
                intent.setType("message/rfc822"); // 真机上使用这行
                intent.putExtra(Intent.EXTRA_EMAIL, new String[] { phoneNum });
                startActivity(intent);
            }
        });

        binding.website.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);
        binding.website.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String phoneNum = binding.website.getText().toString().replace("网址：", "");
                Intent intent = new Intent(Intent.ACTION_VIEW);
                Uri data = Uri.parse(phoneNum);
                intent.setData(data);
                startActivity(intent);
            }
        });

    }
}